<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head th:replace="_fragments:: head(${blog.title})">
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>详情页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../start/css/me.css" th:href="@{/css/me.css}">
    <link rel="stylesheet" href="../start/css/typo.css" th:href="@{/css/typo.css}">
    <link rel="stylesheet" href="../start/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.11.1/tocbot.css">
</head>

<body>
<!-- 导航 -->
<nav th:replace="_fragments :: menu(1)" class="ui inverted attached segment m-padded-tb-mini">
    <div class="ui container">
        <div class="ui stackable menu secondary inverted ">
            <h2 class="ui teal header item">Blog</h2>
            <a href="#" class=" m-item item m-mobile-hide"><i class="home icon"></i>首页</a>
            <a href="#" class=" m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="clone icon"></i>归档</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="info icon"></i>关于我</a>
            <div class="right m-item item m-mobile-hide">
                <div class="ui input inverted transparent icon">
                    <input type="text " placeholder="搜索">
                    <i class="icon search"></i>
                </div>
            </div>
        </div>
    </div>

    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<!-- 主体 -->
<div class="m-padded-tb-massive m-container-small">
    <div class="ui container">
        <div class="ui top attached segment">
            <div class="ui horizontal link list">
                <div class="item">
                    <img src="https://unsplash.it/800/450?image=1005" th:src="@{${blog.user.avatar}}" alt=""
                         class="ui avatar image">
                    <div class="content">
                        <a href="" class="header">
                            <span th:text="${blog.user.nickname}">邓昌荣</span>
                        </a>
                    </div>
                </div>
                <div class="item">
                    <i class="icon calendar"></i>
                    <span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:ss')}">2020-10-01</span>
                </div>
                <div class="item">
                    <i class="eye icon"></i>
                    <span th:text="${blog.views}">11</span>
                </div>
            </div>
        </div>
        <div class="ui attached segment">
            <img class="ui fluid rounded image" th:src="@{${blog.firstPicture}}" style="width: 812px;height: 456px"
                 src="https://unsplash.it/800/450?image=1005">
        </div>

        <div class="ui attached segment">
            <div class="ui basic right aligned segment">
                <div class="ui orange basic label" th:text="${blog.flag}">原创</div>
            </div>
            <h2 class="ui header center aligned" th:text="${blog.title}">你要努力鸭</h2>
            <br>
            <div id="content" class="m-padded-lr-responsive typo typo-selection js-toc-content"
                 th:utext="${blog.content}">
                <h2 id="section1">一、关于 <i class="serif">Typo.css</i></h2>

                <pre><code class="language-css">p { color: red }</code></pre>

                <pre><code class="language-css">p { color: red }</code></pre>

                <p><i class="serif">Typo.css</i> 的目的是，在一致化浏览器排版效果的同时，构建最适合中文阅读的网页排版。</p>
                <h4>现状和如何去做：</h4>

                <p class="typo-first">排版是一个麻烦的问题 <sup><a href="#appendix1"># 附录一</a></sup>，需要精心设计，而这个设计却是常被视觉设计师所忽略的。前端工程师更常看到这样的问题，但不便变更。因为在多个
                    OS 中的不同浏览器渲染不同，改动需要多的时间做回归测试，所以改变变得更困难。而像我们一般使用的
                    Yahoo、Eric Meyer 和 Alice base.css 中采用的 Reset 都没有很好地考虑中文排版。<i class="serif">Typo.css</i>
                    要做的就是解决中文排版的问题。</p>

                <p><strong><i class="serif">Typo.css</i> 测试于如下平台：</strong></p>


            </div>


            <!-- 标签 -->
            <div class="m-padded-lr-large m-padded-tb-small">
                <div class="ui basic teal left pointing label" th:each="tag:${blog.tags}" th:text="${tag.name}">方法论
                </div>
            </div>
            <!-- 赞赏 -->
            <div class="ui center aligned basic segment">
                <button id="payButton" class="ui orange basic circular button">赞赏</button>
            </div>

            <div class="ui flowing popup transition visible animating scale out">
                <div class="ui orange basic label">
                    <div class="ui small images">
                        <div class="image">
                            <img src="../start/img/wechat.jpg" th:src="@{/img/wechat.jpg}" alt=""
                                 class="ui rounded bordered image">
                            <div>微信</div>
                        </div>
                        <div class="image">
                            <img src="../start/img/wechat.jpg" th:src="@{/img/wechat.jpg}" alt=""
                                 class="ui rounded bordered image">
                            <div>支付宝</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui attached positive message">
            <!-- 博客信息 -->
            <div class="ui middle aligned grid">
                <!-- 左边信息 -->
                <div class="eleven wide column">
                    <div class="ui list">
                        <li>作者：<span th:text="${blog.user.nickname}">CRDeng</span><a th:href="@{/me}">(联系)</a></li>
                        <li>发布时间 : <span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:ss')}"></span></li>
                    </div>
                </div>
                <!-- 右边图片 -->
                <div class="five wide column">
                    <img src="../start/img/wechat.jpg" alt="" class="ui right floated rounded bordered image"
                         style="width: 110px;">
                </div>
            </div>
        </div>

        <div class="ui bottom attached segment ">
            <div class="ui teal segment" id="comment-container">
                <!-- 评论 -->

                <div th:fragment="commentList">
                    <div class="ui threaded comments" style="max-width: 100%;">
                        <h3 class="ui dividing header">评论</h3>
                        <div class="comment" th:each="comment:${comments}">
                            <a class="avatar">
                                <img th:src="@{${comment.avatar}}" src="https://unsplash.it/800/450?image=1005">
                            </a>
                            <div class="content">
                                <a class="author">
                                    <span th:text="${comment.nickname}">Matt</span>
                                    <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${comment.adminComment}">博主</div>
                                </a>
                                <div class="metadata">
                                    <span class="date"
                                          th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                </div>
                                <div class="text" th:text="${comment.content}">
                                    How artistic!
                                </div>
                                <div class="actions">
                                    <a class="reply" onclick="reply(this)"
                                       th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}"
                                       data-commentid="1" data-commentnickname="Math">回复</a>
                                </div>
                            </div>

                            <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                                <div class="comment" th:each="reply : ${comment.replyComments}">
                                    <a class="avatar">
                                        <img src="https://unsplash.it/800/450?image=1005" th:src="@{${reply.avatar}}">
                                    </a>
                                    <div class="content">
                                        <a class="author">
                                            <span th:text="${reply.nickname}">小红</span>
                                            <div class="ui mini basic teal left pointing label m-padded-mini" th:if="${reply.adminComment}">博主</div>
                                            <span th:text="|@ ${reply.parentComment.nickname}|"
                                                  class="m-teal">@ 小白</span>
                                        </a>
                                        <div class="metadata">
                                            <span class="date"
                                                  th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Just now</span>
                                        </div>
                                        <div class="text" th:text="${reply.content}">
                                            Elliot you are always so right :)
                                        </div>
                                        <div class="actions">
                                            <a class="reply" onclick="reply(this)"
                                               th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}"
                                               data-commentid="1" data-commentnickname="Math">回复</a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>


                        <!--/*-->
                        <div class="comment">
                            <a class="avatar">
                                <img src="https://unsplash.it/800/450?image=1005">
                            </a>
                            <div class="content">
                                <a class="author">Elliot Fu</a>
                                <div class="metadata">
                                    <span class="date">Yesterday at 12:30AM</span>
                                </div>
                                <div class="text">
                                    <p>This has been very useful for my research. Thanks as well!</p>
                                </div>
                                <div class="actions">
                                    <a class="reply">回复</a>
                                </div>
                            </div>
                            <div class="comments">
                                <div class="comment">
                                    <a class="avatar">
                                        <img src="https://unsplash.it/800/450?image=1005">
                                    </a>
                                    <div class="content">
                                        <a class="author">Jenny Hess</a>
                                        <div class="metadata">
                                            <span class="date">Just now</span>
                                        </div>
                                        <div class="text">
                                            Elliot you are always so right :)
                                        </div>
                                        <div class="actions">
                                            <a class="reply">回复</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="comment">
                            <a class="avatar">
                                <img src="https://unsplash.it/800/450?image=1005">
                            </a>
                            <div class="content">
                                <a class="author">Joe Henderson</a>
                                <div class="metadata">
                                    <span class="date">5 days ago</span>
                                </div>
                                <div class="text">
                                    Dude, this is awesome. Thanks so much
                                </div>
                                <div class="actions">
                                    <a class="reply">回复</a>
                                </div>
                            </div>
                        </div>
                        <!--*/-->
                    </div>

                </div>

            </div>
            <div class="ui form" id="comment-form">
                <input type="hidden" name="blog.id" th:value="${blog.id}">
                <input type="hidden" name="parentComment.id" value="-1">
                <div class="field">
                    <textarea name="content" id="" placeholder="请输入评论信息" cols="30" rows="5"></textarea>
                </div>
                <div class="fields">
                    <!-- 姓名 -->
                    <div class="field m-mobile-wide m-margin-botton-small">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="nickname" placeholder="姓名"
                                   th:value="${session.user}!=null ? ${session.user.nickname}">
                        </div>
                    </div>
                    <!-- 邮箱 -->
                    <div class="field m-mobile-wide m-margin-botton-small">
                        <div class="ui left icon input">
                            <i class="icon mail"></i>
                            <input type="email" name="email" placeholder="邮箱"
                                   th:value="${session.user}!=null ? ${session.user.email}">
                        </div>
                    </div>
                    <!-- 发送 -->
                    <div class="field m-mobile-wide m-margin-botton-small">
                        <button id="commentpost-btn" type="button" class="ui teal m-mobile-wide button"><i
                                class="edit icon"></i> 发布
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<!-- 尾部 -->

<!-- 侧边栏 -->
<div class="m-fixed  m-padded-lr">

    <div class="ui vertical icon buttons ">
        <button type="button" class="ui toc teal teal button">目录</button>
        <a href="#comment-container" class="ui teal button">留言</a>
        <button class="ui wechat icon button"><i class="weixin icon"></i></button>
        <a href="#" class="ui icon teal button"><i class="icon up chevron"></i></a>

    </div>


</div>
<!-- 目录 -->
<div class="ui toc-container flowing popup transition visible animating scale out">
    <div class="js-toc" style="width: 300px;">

    </div>
    <!-- 二维码连接 -->
    <div id="qrcode" class="ui wechat-herf popup transition visible animating scale out"
         style="width: 120px !important;">
        <!-- <img src="./start/img/wechat.jpg" alt="" class="ui rounded image" style="width: 110px !important;"> -->
    </div>
</div>


<footer th:replace="_fragments::footer" class="ui segment vertical inverted m-padded-tb-massive">
    <div class="ui center aligned container">
        <div class="ui inverted stackable divided grid">
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../start/img//wechat.jpg" class="ui rounded image" alt="" style="width: 110px;">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户</a>
                    <a href="#" class="item">用户</a>
                    <a href="#" class="item">用户</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">Email：2495988443@qq.com</a>
                    <a href="#" class="item">QQ: 2495988443</a>

                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header">Blog</h4>
                <p>这是我的个人博客、会分享关于编程、写作、思考相关的任何内容，希望可以给来到这儿的人有所帮助</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="">Copyright © 2016 - 2017 Lirenmi Designed by Lirenmi</p>
    </div>
</footer>


</body>

<!--/*/<th:block th:replace="_fragments :: js">/*/-->

<!--/*/</th:block>/*/-->
<script th:inline="javaScript">
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
    // 赞赏
    $('#payButton').popup({
        popup: $('.flowing.popup'),
        on: 'click',
        position: 'bottom center'
    })
    // 目录插件
    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
        // For headings inside relative or absolute positioned containers within content.
        hasInnerContainers: true
    });
    // 目录
    $('.toc.button').popup({
        popup: $('.toc-container.flowing'),
        on: 'click',
        position: 'left center'
    })
    // 弹出微信二维码
    $('.wechat').popup({
        popup: $('.wechat-herf.popup'),
        position: 'top center'
    })
    //生成二维码链接
    var serurl = "127.0.0.1:8080";
    var url =/*[[@{blog/{id}(id=${blog.id})}]]*/"";
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        text: "http://jindo.dev.naver.com/collie",
        width: 128,
        height: 128,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });

    //评论表单验证
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }
                ]
            },
            content: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的大名'
                }]
            },
            type: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请填写正确的邮箱地址'
                }]
            }
        }
    });

    $('#commentpost-btn').click(function () {
        var boo = $('.ui.form').form('validate form');
        if (boo) {
            console.log('校验成功');
            postData();
        } else {
            console.log('校验失败');
        }

    });

    function postData() {
        $("#comment-container").load(/*[[@{/comments}]]*/"/comments}", {
            "parentComment.id": $("[name='parentComment.id']").val(),
            "blog.id": $("[name='blog.id']").val(),
            "nickname": $("[name='nickname']").val(),
            "email": $("[name='email']").val(),
            "content": $("[name='content']").val()
        }, function (responseTxt, statusTxt, xhr) {
            // $(window).scrollTo($('#comment-container'), 500);
            clearContent();
        });
    }

    function clearContent() {
        $("[name='content']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='content']").attr("placeholder", "请输入评论信息...");
    }

    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');
        $("[name='content']").attr("placeholder", "@" + commentNickname).focus();
        $("[name='parentComment.id']").val(commentId);
        //$(window).scrollTo($('#comment-form'), 500);
    }

    $(function () {
        $("#comment-container").load(/*[[@{/comments/{id}(id=${blog.id})}]]*/"comments/6");
    });

</script>

</html>